Paul Hermans, CC BY-SA 3.0, via Wikimedia Commons.
January 26, 2021
Really, all three. Software-wise, this translates into two main schools:
WYSIWYG–What You See Is What You Get: word processing software, e.g., Microsoft Word1
WISIWIT–What I See Is What I Type: typesetting software, e.g., LaTeX1
R Markdown is a file format for making dynamic documents with R. Kind of half-way between Word and LaTeX.
An R Markdown document is written in markdown and contains text, code, and output.
Ok, what’s markdown?
Markdown is a plain text formatting syntax2: you can read markdown in its source format and still understand it, like this:
Hello, Lab! Y'all still with me?
Practical reasons
Philosophical reasons
If you installed RStudio, congrats! You’re all set to start using R Markdown.
If you prefer to not use RStudio, make sure to install the rmarkdown package.
In either case, make sure to install the tinytex package, which will let you export your work as PDF (sometimes required, i.e., most papers’ Supplementary Information.
Writing text in markdown is easy: just type. You can type formatting too!
*italics* or _italics_ **bold** sub~script~ super^script^
italics
bold
subscript
superscript
If you need headers, mark them with #. The more # in front of some text, the lower the header’s level.
More text formatting here, and we’ll see some in action in just a few.
Right, now to the real deal. Markdown lets you seamlessly switch from writing plain old text to code.
What kind of code? R, obviously, but also Python, Bash, SQL,…
Of course, you got to tell R that you’re about to write some magic text, or it will just spin…
Code in R markdown can be written inline.
For instance this ` r format(Sys.Date(), "%A, %B %d, %Y") ` produces this Tuesday, January 26, 2021.
Use ` to signal the start and the end of a piece of inline code.
Code can also take up a portion of the document—i.e., a chunk. To open and close a code chunk, use ```. Always close code chunks!
Code chunks can contain any piece of code you want, provided you load the appropriate packages and correctly set your working directory.
setwd("/Users/matteo/rmarkdowntour/")
library(tidyverse)
library(knitr)
Don’t mess up, be a
The standard R Markdown output is an HTML file. R uses pandoc to read R Markdown and blurt out a fancy-looking thing.
What’s pandoc, then?
pandoc is the universal document converter. It’s a tiny piece of open source software that can convert almost any document format into any other format. Don’t worry, you don’t need to install anything more!
The output looks beautiful, like the presentation you’re looking at ;)